<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>


<div class="modal-dialog ms-modal-dialog" style="margin-top:50px;" >
  <div class="modal-content">
     
    <div class="modal-header">
      <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
      <h4 class="modal-title">修改帐户信息</h4>
    </div>
      <form class="form-horizontal ms-form form-personal-info" method="POST" action="${ctx.host}/accounts/${account.id}" data-validate="true">
        
        <input type="hidden" name="_method" value="PATCH" />
        
        <input type="hidden" name="accountId" value="${account.id}" />
        
         <div class="modal-body">
             
             <div class="form-group  ms-form-group">
	          <label class="control-label col-xs-3"><span class="text-red">*</span>邮箱：</label>
	          <div class="col-xs-8">
	          	<p  class="form-control-static">${account.email}</p>
	            <input type="hidden"  name="email" value="${account.email}" />
	          </div>
            </div>
	        <div class="form-group  ms-form-group">
	          <label class="control-label col-xs-3"><span class="text-red">*</span>姓名：</label>
	          <div class="col-xs-8">
	            <input type="text" class="form-control" name="username" value="${account.name}" placeholder="姓名" data-validate="required" autocomplete="off" tabindex="3"/>
	          </div>
	        </div>
            <div class="form-group  ms-form-group">
	          <label class="control-label col-xs-3"><span class="text-red">*</span>帐号类型：</label>
	            <div class="col-xs-8 pull-left">
	              <select class="select2 form-control" name="authority" id="isAdmin"  data-validate="required"  tabindex="4">
	              	<c:forEach var="role" items="${secure.rolelist()}">
	                	<option value="${role.name}" <c:if test="${account.authority==role.name }"> selected </c:if>>${role.description}</option>
	                </c:forEach>
	              </select>
	             </div>
            </div>
        
        <div class="form-group  ms-form-group department">
	          <label class="control-label col-xs-3"><span class="text-red">*</span>所在部门：</label>
	            <div class="col-xs-8 pull-left">
	              <select class="select2 form-control" name="departmentId" data-validate="required" value="${account.departmentId}"  tabindex="5" >
	                <c:forEach items="${persist.departments()}" var="department">
	                  <option value="${department.id}" <c:if test="${account.departmentId==department.id }"> selected </c:if>>${department.name}</option>
	                </c:forEach>
	              </select>
	             </div>
            </div>      
        </div>
      <div class="modal-footer">
        <button type="submit" class="btn btn-shadow-success btn-shadow umu-btn" >确定</button>
        <button type="button" class="btn btn-shadow-default btn-shadow umu-btn" data-dismiss="modal">取消</button>
      </div>
      </form>

    
  </div>
</div>
<script type="text/javascript">
var role =document.getElementById("isAdmin").value;
if(role =="ROLE_DEPARTMENT_USER") {
    $('.department').removeClass('hide')
} else {
    $('.department').addClass('hide')
}
</script>